home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABUSESRC.ZIP / AbuseSrc / macabuse / imlib / port / mac / dirent.h < prev    next >
C/C++ Source or Header  |  1997-05-20  |  3KB  |  88 lines

  1. /****************************************************************************************
  2.  *
  3.  *    File:        dirent.h
  4.  *    Created:    7/3/93        By:    George T. Talbot
  5.  *    Purpose:    Implements UNIX-like directory reading for the Macintosh.
  6.  *                This file describes Filesystem-independent directory information.
  7.  *    Modifications:
  8.  *
  9.  *    Notes:
  10.  *            1) These routines will NOT work under A/UX.
  11.  *            2) WD = working directory
  12.  *            3) CD = change directory
  13.  *            4) FS = file system
  14.  *            5) Mac filesystems allow spaces as part of pathnames!
  15.  *            6) All routines which return a path use the default Macintosh path separator,
  16.  *               a colon (":").
  17.  *
  18.  ****************************************************************************************/
  19.  
  20. #ifndef    __dirent_h
  21. #define    __dirent_h
  22.  
  23. /*    Maximum path length for opendir()    */
  24. #define    MAXPATHLEN    255
  25.  
  26. /*
  27.  * Definitions for library routines operating on directories.
  28.  */
  29. typedef    struct __dirdesc {
  30.     /*    PRIVATE FIELDS.  Use the fields & defines below PUBLIC */
  31.     FSSpec    dir_fsp;
  32.     long    dd_off;        /* Current offset (ioWDIndex) in dir (for telldir) */
  33.     int        dd_cached;    /* true if dd_cache_hint points to the next dir to be read    */
  34.  
  35.     struct dirent    **dd_cache_hint;
  36.     struct dirent    **dd_buf;    /* directory data buffer */
  37.  
  38.     /*    PUBLIC    */
  39.     long    dd_fd;                            /* file descriptor (dirID) of this dir    */
  40.  
  41. #define    dd_parent    dir_fsp.parID            /* dirID of parent    */
  42. #define    dd_bsize    1                        /* amount of entries read at a time */
  43. #define    dd_size        sizeof(struct dirent)    /* amount of valid data in buffer */
  44. #define    dd_loc        1
  45. #define    dd_name        dir_fsp.name
  46. #define    dd_volume    dir_fsp.vRefNum
  47.  
  48.     long    dd_numents;    /* Number of files/directories in this directory    */
  49. } DIR;
  50.  
  51. /*    See dirent.c for descriptions of these routines    */
  52. extern    DIR    *opendir(char *dirname);
  53. extern    struct dirent *readdir(DIR *dirp);
  54. extern    int closedir(DIR *dirp);
  55. extern    void seekdir(DIR *dirp, long loc);
  56. extern    long telldir(DIR *dirp);
  57.  
  58. #ifndef    lint
  59.     #define    rewinddir(dirp)    seekdir((dirp), (long)0)
  60. #else
  61.     extern    void rewinddir(DIR *dirp);
  62. #endif
  63.  
  64. /*    Convenient routines    */
  65. extern char    *getwd(char *path);
  66. extern int    chdir(char *path);
  67. extern char    *pathdir(DIR *dirp, char *path);
  68.  
  69. /*    Any errors in above routines (and hopendir()) are put here    */
  70. extern OSErr    dd_errno;
  71. extern char        *dd_separator;    /*    If you're feeling brave, change this to "/"    */
  72. extern int        dd_xform_seps;
  73.  
  74. /*    In case you like errno instead    */
  75. #ifdef UNCOMMENT_ME_IF_YOUVE_GOT_TO_HAVE_ERRNO
  76. #define    errno    dd_errno
  77. #endif
  78.  
  79. /*    This routine is Mac-specific, but very convenient in certain situations    */
  80. OSErr    hgetwd(short vRefNum, long startDirID, char *path, int max_path_len, char *sep);
  81.  
  82. /*    You probably don't want to call this.    */
  83. extern    DIR    *hopendir(char *dirname, short vRefNum, long dirID);
  84.  
  85. #include "sys_dirent.h"
  86.  
  87. #endif    /* !__dirent_h */
  88.